<template>
  <div>
    <input type="text" :value="value" style="display: none" />
    <el-select
      v-model="selected"
      :clearable="true"
      :size="size"
      :placeholder="placeholder"
      @change="handleItemChange"
    >
      <el-option
        v-for="item in bankList"
        :key="item.bank_id"
        :label="item.bank_name"
        :value="item.bank_id"
      ></el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    value: {
      type: String,
      default: '',
    },
    size: {
      type: String,
      default: '',
    },
    placeholder: {
      type: String,
      default: '选择认领银行',
    },
  },
  data() {
    return {
      selected: null,
      bankList: [],
    }
  },
  computed: {},
  watch: {
    value(val) {
      this.selected = val
    },
  },
  created() {
    this.selected = this.value
    this.getData()
  },
  methods: {
    getData() {
      this.$api.getData('credit', 'customer_related_claim_view').then(res => {
        if (!res || !res.data) {
          return
        }
        this.bankList = res.data || []
      })
    },
    handleItemChange(val) {
      this.$emit('input', val)
      this.$emit('change', val)
    },
  },
}
</script>

<style scoped></style>
